package cn.itzqw.mapper;

import cn.itzqw.pojo.Book;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface BookMapper {

    int addBooks(List<Book> books);

    Book searcByTrim(Book book);

    int updateByTrim(Book book);

    List<Book> searchLikeByName(@Param("bookName") String name);

    //注解 形式  适用于简单的SQL语句
    @Select("select * from books ")
    List<Book> searchAllBooks();


    /**
     * 自增key，回显主键bookId
     * @param book  Book对象
     * @return 影响行数
     */
    @Options(useGeneratedKeys = true ,keyProperty = "bookId")
    @Insert("insert into books values(#{bookId},#{bookName},#{bookCounts},#{detail})")
    int addBook(Book book);




}
